# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Jan de Groot <jgc@archlinux.org>

pkgbase=gst-python
pkgname=(gst-python gst-python2)
pkgver=1.14.4
pkgrel=1
pkgdesc="GStreamer Python binding overrides"
url="https://gstreamer.freedesktop.org/"
arch=(x86_64)
license=(LGPL)
makedepends=(python-gobject python2-gobject gst-plugins-base-libs git)
_commit=34b8ce18ca49dc8cb9d03f29d54640e1ef1d10b7  # tags/1.14.4^0
source=("git+https://anongit.freedesktop.org/git/gstreamer/gst-python#commit=$_commit"
        "gst-common::git+https://anongit.freedesktop.org/git/gstreamer/common")
sha256sums=('SKIP'
            'SKIP')

pkgver() {
  cd $pkgbase
  git describe --tags | sed 's/-/+/g'
}

prepare() {
  cd $pkgbase

  git submodule init
  git config --local submodule.common.url "$srcdir/gst-common"
  git submodule update

  NOCONFIGURE=1 ./autogen.sh

  cd ..
  cp -a $pkgbase py2
  cp -a $pkgbase py3
}


_build() (
  cd py$1
  PYTHON=/usr/bin/python$1 ./configure --prefix=/usr
  make
)

build() {
  _build 2
  _build 3
}

check() {
  make -C py3 check
  make -C py2 check
}

package_gst-python() {
  pkgdesc="${pkgdesc//Python/Python 3}"
  depends=(python-gobject gst-plugins-base-libs)

  make -C py3 DESTDIR="$pkgdir" install
}

package_gst-python2() {
  pkgdesc="${pkgdesc//Python/Python 2}"
  depends=(python2-gobject gst-plugins-base-libs)

  make -C py2 DESTDIR="$pkgdir" install
}
